//
//  vdTMXLayer.h
//  Void Dead
//
//  Created by Sidney Just on 02.02.10.
//
//  Copyright © 2009 by Sidney Just
//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
//  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
//  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
//  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#import <Foundation/Foundation.h>

#import "vdNode.h"
#import "vdTexNode.h"
#import "vdAtlasShapeContainer.h"

/**
 * A layer of an TMX node
 **/
@interface vdTMXLayer : vdAtlasShapeContainer {
	//\cond
	int tileHeight;
	int tileWidth;
	int layerWidth;
	int layerHeight;
	
	unsigned int *tiles;
	unsigned int firstGid;
	
	NSString *layerName;
	//\endcond
}

/**
 * The used gid's for the layer
 **/
@property unsigned int *tiles;

/**
 * The first gid
 **/
@property unsigned int firstGid;

/**
 * The height of one tile in pixels
 **/
@property int tileHeight;

/**
 * The width of one tile in pixels
 **/
@property int tileWidth;

/**
 * The number of tiles on the x-axis
 **/
@property int layerWidth;

/**
 * The number of tiles on the y-axis
 **/
@property int layerHeight;

/**
 * The name of the layer, specified in the .tmx file
 **/
@property (nonatomic, readonly) NSString *layerName;

// \cond
- (id)initWithName:(NSString *)_name;
// \endcond

/**
 * Returns the gid of the tile on the position
 @param _point The position of the tile
 @return The gid of the tile
 @remark If the positions isn't inside the layer, this function migth crash due to an segmentation fault!
 **/
- (unsigned int)getTileID:(CGPoint)_point;


/**
 * Sets the tile id (NOT GID!) of the given tile
 @param _point The position of the tile
 @param gid The new tile id (NOT GID!) of the tile
 **/
- (void)setTileID:(CGPoint)_point :(unsigned int)gid;

/**
 * Sets a new gid to all tiles with a given gid
 @param oGid The old gid
 @param nGid The new gid
 **/
- (void)changeAllTilesWithGID:(unsigned int)oGid to:(unsigned int)nGid;

// \cond
- (void)createMap;
// \endcond

@end
